package com.css.zfzx.data.postgresql.yhDisasterPG.repository;

import com.css.zfzx.data.postgresql.yhDisasterPG.repository.entity.YhDisasterFwPostgresqlEntity;
import org.springframework.data.jpa.repository.JpaRepository;
import org.springframework.data.jpa.repository.Query;
import org.springframework.stereotype.Repository;

import java.time.LocalDateTime;

@Repository
public interface YhDisasterFwRepository extends JpaRepository<YhDisasterFwPostgresqlEntity,String> {
    @Query(value = "select fxpc_dcdxbm_sjgl from yh_disaster_fw order by substring(fxpc_dcdxbm_sjgl,22) desc LIMIT 1",
            nativeQuery = true)
    String getGenerateSiteCode();

    @Query(value = "select create_time from yh_disaster_fw  where update_time is null order by create_time desc LIMIT 1",
            nativeQuery = true)
    LocalDateTime findCreateTime();

    @Query(value = "select update_time from yh_disaster_fw where update_time is not null order by update_time desc LIMIT 1",
            nativeQuery = true)
    LocalDateTime findUpdateTime();

    @Query(value = "select fxpc_dcdxbm_sjgl from yh_disaster_fw where yh_project_type=:menu order by substring(fxpc_dcdxbm_sjgl,22) desc LIMIT 1",
            nativeQuery = true)
    String getGenerateSiteCode1(String menu);

    @Query(value = "select create_time from yh_disaster_fw  where update_time is null and yh_project_type=:menu" +
            " order by create_time desc LIMIT 1",
            nativeQuery = true)
    LocalDateTime findCreateTime1(String menu);

    @Query(value = "select update_time from yh_disaster_fw where yh_project_type=:menu and update_time is not null order by update_time desc " +
            "LIMIT 1",
            nativeQuery = true)
    LocalDateTime findUpdateTime1(String menu);
}
